﻿#region Header

// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using DesignByContract;
using Majesty_of_Omega.Model.Structures;

#endregion

namespace Majesty_of_Omega.Config
{
    /// <summary>
    /// Partial extension to generated class PlanetConfiguration
    /// </summary>
    public partial class DeaConfiguration : Spreadsheet
    {
        /// <summary>
        /// Gets the DeaType information object for the dea type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public DeaConfigurationDeaInfoBlock GetDeaType(DeaType type)
        {
            foreach (DeaConfigurationDeaInfoBlock deaConfigurationDea in DeaTypes)
            {
                if (deaConfigurationDea.ID == (int) type)
                {
                    return deaConfigurationDea;
                }
            }
            Ensure.ThrowException(string.Format("There is no DeaType entry for the type with the id {0}", (int) type));
            return null;
        }
    }

    /// <summary>
    /// Enhancement to the generated DeaConfigurationDea class.
    /// The DeaConfigurationDeaInfoBlock describes Icon, Name and the type info of a DEA in the DeaConfiguration.xml file
    /// </summary>
    public partial class DeaConfigurationDeaInfoBlock
    {
        /// <summary>
        /// Gets the type of the DeaConfiguration Block.
        /// </summary>
        /// <value>The type of the dea.</value>
        public DeaType DeaType
        {
            get { return (DeaType) ID; }
        }

        /// <summary>
        /// Gets the URI location of the icon picture. 
        /// This could be used with the UriToImageConverter class"/>
        /// </summary>
        /// <value>The dea icon URI.</value>
        public string DeaIconUri
        {
            get { return @"\Graphics\UI\" + iconField; }
        }
    }
}